﻿namespace block_explorer.NoiseSystem.Nodes
{
    class Combine : INode
    {
        public enum CombineType
        {
            Add,
            Subtract,
            Multiply,
            Divide
        }

        INode mSource1;
        INode mSource2;
        CombineType mType;

        public Combine(INode source1, INode source2, CombineType type)
        {
            mSource1 = source1;
            mSource2 = source2;
            mType = type;
        }

        public double Value(double x, double y, double z)
        {
            double a = mSource1.Value(x, y, z);
            double b = mSource2.Value(x, y, z);

            switch (mType)
            {
                case CombineType.Add:
                    return a + b;
                case CombineType.Subtract:
                    return a - b;
                case CombineType.Multiply:
                    return a * b;
                case CombineType.Divide:
                    return a / b;
            }
            return 0;
        }
    }
}
